#include"heap.h"

void Htest()
{
	Heap hp;
	Hinit(&hp);
	int a[10] = { 54,592,224,45,123,48,9,88,55,922 };
	for (int i = 0; i < 10; i++)
	{
		Adjustdown(a, 10 - i, (8 - i) / 2);
	}
	for (int i = 9; i >= 0; )
	{
		Swap(&a[0], &a[i]);
		i--;
		Adjustdown(a, i, 0);
	}
	for (int i = 0; i < 10; i++)
	{
		printf("%d ", a[i]);
	}
	//int a = 10000;
	//int k = 10;
	//int* n = (int*)malloc(sizeof(int) * a);
	//for (size_t i = 0; i < a; i++)
	//{
	//	n[i] = rand() % 1000000;
	//}
	//n[965] = 1000000 + 1;
	//n[543] = 1000000 + 2;
	//n[734] = 1000000 + 3;
	//n[765] = 1000000 + 4;
	//n[46] = 1000000 + 5;
	//n[75] = 1000000 + 6;
	//n[547] = 1000000 + 7;
	//n[325] = 1000000 + 8;
	//n[557] = 1000000 + 9;
	//n[34] = 1000000 + 10;
	//for (int i = 0; i < k; i++)
	//{
	//	Hpush(&hp, n[i]);
	//}
	//for (int i = (k - 1 - 1) / 2; i >= 0; i--)
	//{
	//	Adjustdown((&hp)->a, (&hp)->size, i);
	//}
	//for (int i = k; i < a; i++)
	//{
	//	if (n[i] > (&hp)->a[0])
	//	{
	//		(&hp)->a[0] = n[i];
	//		Adjustdown((&hp)->a, (&hp)->size, 0);
	//	}
	//}
	//for (int i = 0; i < k; i++)
	//{
	//	printf("%d ", Htop(&hp));
	//	Hpop(&hp);
	//	Adjustdown((&hp)->a, (&hp)->size, 0);
	//}
}

int main()
{
	Htest();
	return 0;
}